package com.zhanghe.mall.service.vo;

import com.zhanghe.mall.pojo.Permissions;
import com.zhanghe.mall.pojo.RolePermissions;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class AccountPermissionsVO {

    public Long id;

    public String name;

    public String url;

    public String type;

    public List<AccountPermissionsVO> child;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<AccountPermissionsVO> getChild() {
        return child;
    }

    public void setChild(List<AccountPermissionsVO> child) {
        this.child = child;
    }

    public static List<AccountPermissionsVO> transformFromAcccountPermissionsList(List<Permissions> list){
        List<AccountPermissionsVO> result = new ArrayList<>();
        for( Permissions permissions : list){
            AccountPermissionsVO vo = new AccountPermissionsVO();
            BeanUtils.copyProperties(permissions,vo);
            result.add(vo);
        }
        return result;
    }
    public static AccountPermissionsVO transformFromRolePermissions(RolePermissions rolePermissions){
        AccountPermissionsVO vo = new AccountPermissionsVO();
        BeanUtils.copyProperties(rolePermissions.getPermissions(),vo);
        return vo;
    }

    @Override
    public String toString() {
        return "AccountPermissionsVO{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", url='" + url + '\'' +
                ", type='" + type + '\'' +
                ", child=" + child +
                '}';
    }
}
